package com.cake.ssm.service.impl;

import com.cake.ssm.dao.CouponMapper;
import com.cake.ssm.po.Coupon;
import com.cake.ssm.service.CouponService;
import org.apache.logging.log4j.core.appender.rolling.action.DeleteAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;

/**
 * Created by lijiawang1 on 2017/4/23.
 */
@Service
@Transactional
public class CouponServiceImpl implements CouponService{

    @Autowired
   private CouponMapper couponMapper;

    public void InsertCoupon(Coupon coupon)throws Exception {
        couponMapper.InsertCoupon(coupon);
    }

    public List<Coupon> SelectAllCoupon() throws Exception {
        List<Coupon> list=null;
        if(couponMapper.SelectAllCoupon()!=null) {
            list= couponMapper.SelectAllCoupon();
        }
        return list;
    }

    public Coupon SelectByCouponId(String id) throws Exception {
        Coupon coupon=null;
        if(couponMapper.SelectByCouponId(id)!=null) {
            coupon = couponMapper.SelectByCouponId(id);
        }
        return coupon;
    }public void UpdateCoupon(Coupon coupon)throws Exception
    {
        System.out.println("UpdateCoupon==="+coupon);
        couponMapper.UpdateCoupon(coupon);
    }

    public void DeleteCoupon(String id) throws Exception {
        couponMapper.DeleteCoupon(id);
    }
}
